package logic

import (
	"context"
	"good_srv/model/mysql"

	"good_srv/good"
	"good_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *good.UserListRequest) (*good.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var user []mysql.User
	mysql.DB.Find(&user)
	var alluser []*good.UserList
	for _, m := range user {
		lists := good.UserList{
			UserId: m.UserId,
			Phone:  m.Phone,
			Times:  m.Times,
			Status: m.Status,
		}
		alluser = append(alluser, &lists)
	}
	return &good.UserListResponse{
		List: alluser,
	}, nil
}
